import 'package:flutter/material.dart';

class IndexPage extends StatefulWidget {
  @override
  _IndexPageState createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('index页'),
      ),
      body: new Center(
        child: buildGrid(),
      ),
    );
  }
}

List<Container> _buildGridTileList(int count) {
  return new List<Container>.generate(
      count,
          (int index) =>
          new Container(child: new Image.network(index%2==0 ? 'https://zzm888.oss-cn-shenzhen.aliyuncs.com/avatar.jpg' : 'https://zzm888.oss-cn-shenzhen.aliyuncs.com/default.png')));
}

Widget buildGrid() {
  return new GridView.extent(
      maxCrossAxisExtent: 150.0,
      padding: const EdgeInsets.all(4.0),
      mainAxisSpacing: 4.0,
      crossAxisSpacing: 4.0,
      children: _buildGridTileList(30));
}